<template>
<div>
  <el-button type="text" @click="dakai">(赋值打开)打开嵌套表单的 Dialog</el-button>
  <el-button type="text" @click="dialogFormVisible = true">打开嵌套表单的 Dialog</el-button>

<el-dialog title="收货地址" :visible.sync="dialogFormVisible" @close="closeDialog">
  <el-form :model="form" ref="form">
    <el-form-item label="活动名称" :label-width="formLabelWidth" prop="name">
      <el-input v-model="form.name" auto-complete="off"></el-input>
    </el-form-item>
    <el-form-item label="活动区域" :label-width="formLabelWidth" prop="region">
      <el-select v-model="form.region" placeholder="请选择活动区域">
        <el-option label="区域一" value="shanghai"></el-option>
        <el-option label="区域二" value="beijing"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item>
    <el-button type="primary" @click="resetForm('form')">确 定</el-button>
  </el-form-item>
  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button @click="cancle()">取 消</el-button>
    <el-button type="primary" @click="resetForm('form')">确 定</el-button>
  </div>
</el-dialog>
<el-select v-model="value" placeholder="请选择">
    <el-option
      v-for="item in options"
      :key="item.value"
      :label="item.label"
      :value="item.value">
    </el-option>
  </el-select>
  <el-button @click="value='1'">点击</el-button>
</div>
</template>

<script>
export default {
  data () {
    return {
      options: [{
        value: '1',
        label: '黄金糕'
      }, {
        value: '2',
        label: '双皮奶'
      }, {
        value: '3',
        label: '蚵仔煎'
      }, {
        value: '4',
        label: '龙须面'
      }, {
        value: '5',
        label: '北京烤鸭'
      }],
      value: '',
      dialogTableVisible: false,
      dialogFormVisible: false,
      form: {
      },
      formLabelWidth: '120px'
    }
  },
  methods: {
    dakai () {
      this.dialogFormVisible = true
      this.form.name = '111'
      this.form.region = '区域二'
    },
    cancle () {
      this.form = {
        name: '',
        region: ''
      }
      this.dialogFormVisible = false
    },
    closeDialog () {
      console.log('111111')
      this.$refs.form.resetFields()
    },
    resetForm (formName) {
      this.$refs[formName].resetFields()
    }
  }
}
</script>
